package mop.controller;

import java.util.List;

import mop.exception.IllegalIdException;
import mop.model.World;
import mop.model.project.Project;
import mop.model.project.ProjectInterface;

/**
 * RemoveProjectController
 * 
 * Use case controller for the removal of a project (use case 6).
 * 
 * @author	MOP Team 7
 */
public class RemoveProjectController extends UseCaseController
{	
	/**
	 * Constructor
	 * @see UseCaseController#UseCaseController(World)
	 */
	public RemoveProjectController(World s)
	{
		super(s);
	}
	
	/**
	 * Returns a list of all projects as interfaces.
	 * @return	A list of project interfaces.
	 */
	public List<ProjectInterface> getProjectList()
	{
		return super.getAllProjects();
	}
	
	/**
	 * Removes a Project with the given description.
	 * 
	 * @param 	p
         *              The project id.
	 * @effect	Removes all tasks that are assigned to the project.
	 * @effect	Removes dependencies of other tasks to the task in the project.
	 * @throws 	IllegalIdException
	 * 			Thrown when the description is invalid or does not exist.
	 */
	public void removeProject(String p) 
		throws IllegalIdException
	{
		Project project = super.getWorld().getProjectDataBase().find(p);
		project.remove();
	}
	
	
	/***************************************************************************
	 * 								Visit
	 ***************************************************************************/
	
	/**
	 * Make a CallBack to the visitor
	 * @param v the visitor
	 */
	public void accept(ControllerVisitor v)
	{
		v.visit(this);
	}
	
	/***************************************************************************
	 * 								Acl
	 ***************************************************************************/
	
	@Override
	public String getAssetId() {
		return "RemoveProject";
	}
}